package domain;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;

public class ArticuloRepositoryMemImpl implements ArticuloRepository {
  private Map<String,Articulo> articulos;
  
  ArticuloRepositoryMemImpl() {
    articulos = new HashMap<String,Articulo>();
  }
  public boolean insertArticulo(Articulo prof) {
	System.out.println("insertArticulo");
    if (articulos.containsKey(prof.getId()))
      return false;
    else
      articulos.put(prof.getId()+"",prof);
    return true;
  }
  public boolean deleteArticulo(Articulo prof) {
	System.out.println("deleteArticulo");
    if (!articulos.containsKey(prof.getId()))
      return false;
    else
      articulos.remove(prof.getId());
    return true;
  }
  public Articulo findArticulo(int id) {
	System.out.println("findArticulo");
    if (!articulos.containsKey(id))
      return null;
    else
      return articulos.get(id);
  }
  public boolean updateArticulo(Articulo prof) {
	System.out.println("updateArticulo");
	System.out.println(prof.getId()+"");
    if (!articulos.containsKey(prof.getId()+""))
      return false;
    else
      articulos.put(prof.getId()+"",prof);
    return true;
  }
  public Collection findAllArticulo() {
    return articulos.values();
  }
  public void setArticulos(Map articulos) {
    this.articulos = articulos;
  }
}